home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / gema26a / int70.s < prev    next >
Text File  |  1995-10-15  |  3KB  |  171 lines

  1.  
  2. ************************************************
  3. *                                              *
  4. *  $70 interrupt test by Jedi from Sector One  *
  5. *                                              *
  6. ************************************************
  7.  
  8.         header
  9.  
  10.         move cs,a
  11.         move a,ds
  12.         bsr installISR
  13.  
  14. * Comment the following line if you want to kill that nasty demo after
  15. * having pressed a key
  16.  
  17.         bra.s resid
  18.  
  19.         xor a,a
  20.         trap #$16
  21.         bsr uninstallISR
  22.  
  23.         move #$4c00,a
  24.         trap #$21
  25.  
  26. resid   move #@end,d
  27.         move #$3100,a
  28.         trap #$21
  29.  
  30. * readRTC : ax = index
  31.  
  32. readRTC pushf
  33.         intoff
  34.         or.b #$80,a
  35.         out.b a,$70
  36.         bra.s *+2
  37.         in.b $71,a
  38.         push a
  39.         bra.s *+2
  40.         move.b #$d,a
  41.         out.b a,$70
  42.         bra.s *+2
  43.         in.b $71,a
  44.         pop a
  45.         popf
  46.  
  47.         rts
  48.  
  49. * setRTC : ax = index ; dl = value
  50.  
  51. setRTC  pushf
  52.         push a
  53.         intoff
  54.  
  55.         or.b #$80,a
  56.         out.b a,$70
  57.         bra.s *+2
  58.  
  59.         move.b d,a
  60.  
  61.         out.b a,$71
  62.         bra.s *+2
  63.         move.b #$d,a
  64.         out.b a,$70
  65.         bra.s *+2
  66.         in.b $71,a
  67.         pop a
  68.         popf
  69.  
  70.         rts
  71.  
  72. installISR
  73.         move #$3570,a
  74.         trap #$21
  75.         cs:move b,old70int
  76.         cs:move es,old70int+2
  77.         move #int70proc,d
  78.         push ds
  79.         move cs,a
  80.         move a,ds
  81.         move #$2570,a
  82.         trap #$21
  83.         pop ds
  84.  
  85.         move #$b,a
  86.         bsr readRTC
  87.         or.b #$40,a
  88.         move a,d
  89.         move #$b,a
  90.         bsr setRTC
  91.         move #$c,a
  92.         bsr readRTC
  93.  
  94.         move #$a,a
  95.         bsr readRTC
  96.         and.b #$f0,a
  97.         or.b #8,a
  98.         move a,d
  99.         move #$ah,a
  100.         bsr setRTC
  101.  
  102.         intoff
  103.         in.b $a1,a
  104.         and.b #$fe,a
  105.         bra.s *+2
  106.         out.b a,$a1
  107.         inton
  108.  
  109.         rts
  110.  
  111. uninstallISR
  112.         move #$b,a
  113.         bsr readRTC
  114.         and.b #$bf,a
  115.         move.b a,d
  116.         move #$b,a
  117.         bsr setRTC
  118.         move #$a,a
  119.         bsr readRTC
  120.         and.b #$f0,a
  121.         or.b #6,a
  122.         move a,d
  123.         move #$a,a
  124.         bsr setRTC
  125.         push ds
  126.         move #$2570,a
  127.         cs:lds old70int,d
  128.         trap #$21
  129.         pop ds
  130.  
  131.         rts
  132.  
  133. * Here is the routine called periodically
  134.  
  135. int70proc
  136.         push a
  137.         push d
  138.         push es
  139.  
  140.         move #$3c8,d
  141.         xor.b a,a
  142.         out.b a,d
  143.         inc d
  144.         out.b a,d
  145.         out.b a,d
  146. jerky   move.b #127,a
  147.         out.b a,d
  148.         cs:inc.b jerky+1
  149.  
  150.         move #$c,a
  151.         bsr readRTC
  152.  
  153.         intoff
  154.         move.b #$20,a
  155.         out.b a,$a0
  156.         out.b a,$20
  157.         pop es
  158.         pop d
  159.         pop a
  160.         rti
  161.  
  162. old70int
  163.         dc.l 0
  164.  
  165.         segment
  166.         ds.l $400
  167.         stack
  168.  
  169.         segment
  170. end
  171.